package com.anc.platform.model.platform.service.impl;

import com.anc.platform.model.platform.entity.ScmLogisticsCompany;
import com.anc.platform.model.platform.mapper.ScmLogisticsCompanyMapper;
import com.anc.platform.model.platform.service.IScmLogisticsCompanyService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 物流公司维护表 服务实现类
 * </p>
 *
 * @author Anc
 * @since 2022-07-02
 */
@Service
public class ScmLogisticsCompanyServiceImpl extends ServiceImpl<ScmLogisticsCompanyMapper, ScmLogisticsCompany> implements IScmLogisticsCompanyService {
    @Autowired
    private ScmLogisticsCompanyMapper scmLogisticsCompanyMapper;
    @Override
    public List<ScmLogisticsCompany> findBytypeList(Integer logisticsCompanyType) throws InterruptedException {
        LambdaQueryWrapper<ScmLogisticsCompany> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(ScmLogisticsCompany::getLogisticType, logisticsCompanyType);
        wrapper.eq(ScmLogisticsCompany::getIsDelete, 0);

        return this.list(wrapper);
    }

    @Override
    public ScmLogisticsCompany findByCompanyName(String companyName,Integer logisticType) {
        LambdaQueryWrapper<ScmLogisticsCompany> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(ScmLogisticsCompany::getLogisticCompanyName, companyName);
        wrapper.eq(ScmLogisticsCompany::getLogisticType, logisticType);
        return this.getOne(wrapper);
    }
    @Async("asyncTaskExecutor")
    @Override
    public List<ScmLogisticsCompany> testFind(int i) {
        try {
            Thread.sleep(8000L);
            System.out.println("休眠成功");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return scmLogisticsCompanyMapper.testFind(i);
    }
}

